<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Writings extends Model
{
    protected $table="writings";
    public function getMasterAttribute($value){
        return explode(',',$value);
    }
    public function setMasterAttribute($value){
        $this->attributes['master']=implode(',',$value);
    }
    public function user(){
        return $this->belongsTo('App\User','author_id');
    }
    public function theme(){
        return $this->belongsTo('App\Theme','theme_id');
    }
    public function comment(){
        return $this->hasOne('App\WritingComment','writing_id');
    }
    public function like(){
        return $this->hasOne('App\WritingLike','writing_id');
    }
}
